﻿// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.



using IdentityServer4;
using IdentityServer4.Models;

using System.Collections.Generic;

namespace MyIdentity
{
    public static class Config
    {
        public static IEnumerable<IdentityResource> IdentityResources =>
            new IdentityResource[]
            {
                new IdentityResources.OpenId(),
                new IdentityResources.Profile(),
            };
        public static IEnumerable<ApiResource> ApiResources =>
         new ApiResource[]
         {
                new ApiResource("orderApi","订单服务")
                {
                    ApiSecrets ={ new Secret("orderApisecret".Sha256()) },
                    Scopes = { "orderScope" }
                },
                new ApiResource("productApi","产品服务")
                {
                    ApiSecrets ={ new Secret("productApisecret".Sha256()) },
                    Scopes = { "productScope" }
                },
         };
        public static IEnumerable<ApiScope> ApiScopes =>
            new ApiScope[]
            {
                new ApiScope("orderScope"),
                new ApiScope("productScope"),
            };

        public static IEnumerable<Client> Clients =>
            new Client[]
            {
                // m2m client credentials flow client
                new Client
                {
                    ClientId = "webclient",
                    ClientName = "webclient",

                    AllowedGrantTypes = GrantTypes.Code,
                    ClientSecrets = { new Secret("webclient".Sha256()) },

                     //RedirectUris = { "http://mymvc:5227/signin-oidc" },
                     //FrontChannelLogoutUri = "http://mymvc:5227/signout-oidc",
                     //PostLogoutRedirectUris = { "http://mymvc:5227/signout-callback-oidc" },
                    
                    // RedirectUris = { "http://localhost:5227/signin-oidc" },
                    //FrontChannelLogoutUri = "http://localhost:5227/signout-oidc",
                    //PostLogoutRedirectUris = { "http://localhost:5227/signout-callback-oidc" },

                    //RedirectUris = { "https://localhost:7149/signin-oidc" },
                    //FrontChannelLogoutUri = "https://localhost:7149/signout-oidc",
                    //PostLogoutRedirectUris = { "https://localhost:7149/signout-callback-oidc" },

                    //RedirectUris = { "https://101.126.19.134:7149/signin-oidc" },
                    //FrontChannelLogoutUri = "https://101.126.19.134:7149/signout-oidc",
                    //PostLogoutRedirectUris = { "https://101.126.19.134:7149/signout-callback-oidc" },



                    RedirectUris = { "https://www.liujian520.asia/signin-oidc" },//7149
                    FrontChannelLogoutUri = "https://www.liujian520.asia/signout-oidc",
                    PostLogoutRedirectUris = { "https://www.liujian520.asia/signout-callback-oidc" },
                    AllowedCorsOrigins = new List<string>
                    {
                        "https://www.liujian520.asia"
                    },

                    //RedirectUris = { "http://host.docker.internal:5227/signin-oidc" },
                    //FrontChannelLogoutUri = "http://host.docker.internal:5227/signout-oidc",
                    //PostLogoutRedirectUris = { "http://host.docker.internal:55227088/signout-callback-oidc" },
                                //允许将token通过浏览器传递
            AllowAccessTokensViaBrowser=true,
                    AllowedScopes = {  
                        IdentityServerConstants.StandardScopes.OpenId,
                        IdentityServerConstants.StandardScopes.Profile,
                        "orderScope", "productScope" }
                },

                // interactive client using code flow + pkce
                //new Client
                //{
                //    ClientId = "interactive",
                //    ClientSecrets = { new Secret("49C1A7E1-0C79-4A89-A3D6-A37998FB86B0".Sha256()) },
                    
                //    AllowedGrantTypes = GrantTypes.Code,

                //    RedirectUris = { "https://localhost:44300/signin-oidc" },
                //    FrontChannelLogoutUri = "https://localhost:44300/signout-oidc",
                //    PostLogoutRedirectUris = { "https://localhost:44300/signout-callback-oidc" },

                //    AllowOfflineAccess = true,
                //    AllowedScopes = { "openid", "profile", "scope2" }
                //},
            };
    }
}